package com.hqd.ch03.v50.context;

import com.hqd.ch03.v50.beans.BeansException;
import com.hqd.ch03.v50.beans.factory.config.BeanFactoryPostProcessor;
import com.hqd.ch03.v50.beans.factory.config.ConfigurableListableBeanFactory;
import com.hqd.ch03.v50.core.env.ConfigurableEnvironment;
import com.hqd.ch03.v50.core.metrics.ApplicationStartup;
import com.hqd.ch03.v50.io.ProtocolResolver;

import java.io.Closeable;

public interface ConfigurableApplicationContext extends ApplicationContext, Lifecycle, Closeable {

    String CONFIG_LOCATION_DELIMITERS = ",; \t\n";
    String CONVERSION_SERVICE_BEAN_NAME = "conversionService";
    String LOAD_TIME_WEAVER_BEAN_NAME = "loadTimeWeaver";
    String ENVIRONMENT_BEAN_NAME = "environment";
    String SYSTEM_PROPERTIES_BEAN_NAME = "systemProperties";
    String SYSTEM_ENVIRONMENT_BEAN_NAME = "systemEnvironment";
    String APPLICATION_STARTUP_BEAN_NAME = "applicationStartup";
    String SHUTDOWN_HOOK_THREAD_NAME = "SpringContextShutdownHook";

    void setId(String id);

    void setParent(ApplicationContext parent);

    @Override
    ConfigurableEnvironment getEnvironment();

    void setEnvironment(ConfigurableEnvironment environment);

    ApplicationStartup getApplicationStartup();

    void setApplicationStartup(ApplicationStartup applicationStartup);

    void addBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor);

    void addApplicationListener(ApplicationListener<?> listener);

    void setClassLoader(ClassLoader classLoader);

    void addProtocolResolver(ProtocolResolver resolver);

    void refresh() throws BeansException, IllegalStateException;

    void registerShutdownHook();

    @Override
    void close();

    boolean isActive();

    ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException;
}
